
var bankCode="";
$(function() {
	//充值方式选中
	$(".pay_platform").children().bind('click',function(){
		 $(".pay_platform").children().removeClass('select');
		 $(this).addClass("select");
	});
	
	//充值
		var foo=	function() {
				var amount = $("#amount").val().replace(/\s+/g, ""); //获取充值金额
				var bankType = "";//充值类型作选择跳转的判断条件
				
				//获取充值类型 将每个充值方式的class属性作为充值类型
				$(".pay_platform").children().each(function(){
					if($(this).attr("class") == "select"){
						bankType = $(this).children("a").attr("class");
					}
				});
				
			    if("1" != $("#isValidData").val())  //1代表页面数据合法  0代表页面数据不合法
	            {
	            	return false;
	            }
			    
				if(bankType == ""){
					$("#amountMsg").html("请选择充值方式");
					document.getElementById("amountMsg").style.display="inline";
					return false;
				}
				if (amount.replace(/\s+/g, "") == "") {
					$("#amountMsg").html("请输入充值金额");
					document.getElementById("amountMsg").style.display="inline";
					return false;
				}
				if (amount.indexOf(".")==amount.length-1) {
					$("#amountMsg").html("金额格式错误");
					document.getElementById("amountMsg").style.display="inline";
					return false;
				}
				var count = amount.split(".");
				if (count.length == 2) {
					if (count[1].length > 2) {
						$("#amountMsg").html("充值金额最多是两位小数");
						document.getElementById("amountMsg").style.display="inline";
						return false;
					}
				}
				if (amount <1) {
					$("#amountMsg").html("充值金额不能小于1元");
					return false;
				}  
				switch (bankType) {
				case "llzf":
					$.layer({
						title : [ '充值提示', true ],
						area : [ 'auto', 'auto' ],
						dialog : {
							btns : 0,
							type : 3,
							msg : $("#rechageMsg").html()
						}
					});
					window.open(ctx_root+ "/pay/payAction_lianPay.action?amount="+ amount + "&bankCode=" + bankCode);
					break;
				case "hczf":
					$.layer({
						title : [ '充值提示', true ],
						area : [ 'auto', 'auto' ],
						dialog : {
							btns : 0,
							type : 3,
							msg : $("#ccpssrechageMsg").html()
						}
					});
					window.open(ctx_root+ "/pay/payAction_huicaoPay.action?amount="+ amount + "&bankCode=" + bankCode);
					break;
				case"gfb":
					$.layer({
						title : [ '充值提示', true ],
						area : [ 'auto', 'auto' ],
						dialog : {
							btns : 0,
							type : 3,
							msg : $("#gfbrechageMsg").html()
						}
					});
					window.open(ctx_root+ "/pay/payAction_gfPay.action?amount="+ amount + "&bankCode=" + bankCode);
					break;
				case "bf":
					$.layer({
						title : [ '充值提示', true ],
						area : [ 'auto', 'auto' ],
						dialog : {
							btns : 0,
							type : 3,
							msg : $("#baofoorechageMsg").html()
						}
					});
					window.open(ctx_root+ "/pay/payAction_baoFooPay.action?amount="+ amount);
					break;
				}
			};
		$("#torecharge").bind("click",foo);	
	
		$("#i_agree").click(function(){
			if($(this).is(':checked')){
				$("#torecharge").css("background","none repeat scroll 0 0 #f40");
				$("#torecharge").attr("href","javascript:void(0);");
				$("#torecharge").bind("click",foo);
			}else{
				$("#torecharge").css("background","none repeat scroll 0 0 gray");
				$("#torecharge").removeAttr("href");
				$("#torecharge").unbind( "click",foo);
			}
		});
});

// 输入验证
function rcalculate(amount) {
	if (isNaN(Number(amount))) {
		$("#amountMsg").html("充值金额格式错误");
		document.getElementById("amountMsg").style.display="inline";
		$("#amount").val("");
                $("#isValidData").val("0");   //0代表页面数据不合法
		return false;
	}
	// 只能输入小数点后两位
	var indexOfPoint = amount.indexOf('.');
	var t1 = amount.substring(0, 1);
	var t2 = amount.substring(1, 2);
	if (indexOfPoint != -1) { 
		if (amount.length > indexOfPoint + 3) {
			$("#amount").val(amount.substring(0, indexOfPoint + 3));
		}
	}if ((t1 == 0 && t2 == 0 && t2 != '')//不能输入类似金额00012
		|| (t1 == 0 && t2 != 0 && t2 != '.')) {
	     $("#amount").val('');
	}if (Number(amount) < 1) {
		$("#amountMsg").html("充值金额不能小于1元");
		document.getElementById("amountMsg").style.display="inline";
                $("#isValidData").val("0");  //0代表页面数据不合法
		return false;
	}
	checkRechargeAmount(amount);
	/*$("#amountMsg").html("");
	document.getElementById("amountMsg").style.display="none";*/
}

//检查充值金额是否超过限制额度
function checkRechargeAmount(amount)
{
   $.ajax
   ({
       url: 'fundRecord_checkRechargeAmount.action',
       type: 'POST',
       data : {
    	   "amount" : amount//充值金额
       },
       dataType: 'text',
       error: function()
       {
           alert('Error!');
       },
       success: function(result)
       {
            if(result == "isOK"){//需要验证码提交 跳出验证码对话框
               $("#amountMsg").html("");
               document.getElementById("amountMsg").style.display="none";
               $("#isValidData").val("1"); //1代表页面数据合法
            }
            else
            {
               $("#amountMsg").html(result);
               document.getElementById("amountMsg").style.display="inline";
               $("#isValidData").val("0");  //0代表页面数据不合法
            }
       }
   });    
}


// ---------------------------转账-------------------------
	var tflag=true;
	var tflags=true;
	
   function sureTransfer(remark) {//remark=1表示按钮确认转账 2表示输入验证码按钮确定
			if(!tflag){return;}
			var amount = $("#transferamount").val();
			var name = document.getElementById("name").innerHTML;// 姓名
			var accname = $("#accname").val();// 好友惠信号
			var otherUserId = $("#otherUserId").val();// 好友id
			var paypassword = $("#paypassword").val();// 支付密码
			var safePayAmount = $("#safePayAmount").val();//转账限额金额
			var cash=trim($("#cash").val());
			
			var systransferFeeRate = $("#systransferFeeRate").val();//互转费率
			var limitTranMoney=$("#limitTranMoney").val();//单日互转最高金额
			var freeRateMoney=cash;
			
			var mmo=(cash*systransferFeeRate/100);
			var maxTranMoney=tomyToFixed((cash-tomyToFixed(mmo+""))+"");//扣除手续费 最多可以转账金额 截取小数点后两位 不用四舍五入
			
			var fmo=(amount*systransferFeeRate/100);
			var fee=tomyToFixed(fmo+"");//手续费 截取小数点后两位 不用四舍五入
			
			if(systransferFeeRate>0){
			   freeRateMoney=tomyToFixed((cash-fee)+"");//算出手续费后的余额
			}
			
			var money = amount-freeRateMoney;
			var bigAmount=amount-cash;
			
			if (trim(accname) == "" || trim(accname).length == 0) {
				$("#accnameMsg").html("请输入对方惠信号码");
				document.getElementById("accnameMsg").style.display="inline";
				return false;
			}else if(trim(name) == "" || trim(name).length == 0 || trim(name)=="***"){
				$("#name").html("");
				$("#nameMsg").html("对方真实姓名不能为空");
				document.getElementById("nameMsg").style.display="inline";
				return false;
			}else if (amount.replace(/\s+/g, "") == "") {
				$("#transferamountMsg").html("请输入转账金额");
				document.getElementById("transferamountMsg").style.display="inline";
				$("#nameMsg").html("");
				document.getElementById("nameMsg").style.display="none";
				return false;
			}
			else if (amount.indexOf(".")==amount.length-1) {
				$("#transferamountMsg").html("金额格式错误");
				document.getElementById("transferamountMsg").style.display="inline";
				return false;
			}
			var count = amount.split(".");
			if (count.length == 2) {
				if (count[1].length > 2) {
					$("#transferamountMsg").html("转账金额最多是两位小数");
					document.getElementById("transferamountMsg").style.display="inline";
					return false;
				}
			}
			if (amount == 0) {
				$("#transferamountMsg").html("转账最小金额不能为0元");
				document.getElementById("transferamountMsg").style.display="inline";
				return false;
			} /*else if ((trim(amount).length > 6&&amount.indexOf(".")==-1)||(trim(amount).length > 9&&amount.indexOf(".")>0)) {
				$("#transferamountMsg").html("转账金额长度不能超过6位数");
				document.getElementById("transferamountMsg").style.display="inline";
				return false;
			}*/else if(Number(money)>0){
				$("#transferamountMsg").html("余额不足  (扣除手续费: "+fee+" 元,最多还可以转账金额: "+maxTranMoney+" 元)");
				if(bigAmount>0){
					$("#transferamountMsg").html("余额不足");
				}
				document.getElementById("transferamountMsg").style.display="inline";
				changeForbidden(2);
				return false;
			}else if (trim(paypassword) == "" || trim(paypassword).length == 0) {
				$("#paypasswordMsg").html("请输入支付密码");
				document.getElementById("paypasswordMsg").style.display="inline";
				return false;
			} else if (trim(paypassword).length < 8
					|| trim(paypassword).length > 16) {
				$("#paypasswordMsg").html("支付密码输入不正确");
				document.getElementById("paypasswordMsg").style.display="inline";
				return false;
			}
			
            var code="";//手机验证码
			$("#paypasswordMsg").html("");
			document.getElementById("paypasswordMsg").style.display="none";
		    if(remark!=1){ //输入验证码后 点击确认
			    code = $("#transferPaySmsCode").val();
				if(trim(code)==""){
					$("#transferPaySmsMsg").html("请输入手机验证码");
					document.getElementById("transferPaySmsMsg").style.display="inline";
					return;
				}else if(isNaN(Number(trim(code)))||trim(code).length!=6){
					$("#transferPaySmsMsg").html("手机验证码是6位数字");
					document.getElementById("transferPaySmsMsg").style.display="inline";
					return;
				}
		   }
		   sureTran_Sub(amount, accname,paypassword,otherUserId,code,systransferFeeRate,cash,limitTranMoney);
}
   
   //确定转账
   function sureTran_Sub(applyAmount, accName,passw,otherUserId,code,systransferFeeRate,cash,limitTranMoney) {
	   var ii = layer.load('提交中...');
		$("#transferPaySmsMsg").html("");//清空验证信息
		document.getElementById("transferPaySmsMsg").style.display="none";
		
	   if (this.ajaxRequest_ != undefined && this.ajaxRequest_.readyState < 4) {//防止重复提交
           return;
       }else{
          this.ajaxRequest_=$.ajax({
            type : "POST",
            url : "fundRecord_sureTransfer.action",
            data : {
               "transfemoney" : applyAmount,//转账金额
               "user.accName" : accName,//好友惠信号
               "user.payPwd":passw,
               "teleCode":code,//手机验证码
               "sysTransferFeeRate":systransferFeeRate,//转账费率
               "cash":cash//余额
            },
            dataType : 'text',
            success : function(data) {
               if(data == "isSendMesCode"){//需要验证码提交 跳出验证码对话框
                  $("#transferPaySmsCode").val('');//清空验证码文本框
                   layer.close(ii);
                  var remark="transfer";
                  $("#"+remark+"PaySmsMsg").html('');
                  resetTimer(remark+"PaySms");
                  $("#"+remark+"PaySms").show();
                  $("#"+remark+"PaySmsD").show();
               }else if(data == "error"){
                  layer.close(ii);
                  $("#paypasswordMsg").html("支付密码错误,请重新输入");
                  document.getElementById("paypasswordMsg").style.display="inline";
               }else if(data == "teleCodeError"){
                  layer.close(ii);
                  $("#transferPaySmsMsg").html("验证码错误,请重新输入");
                  document.getElementById("transferPaySmsMsg").style.display="inline";
               }else if(data.indexOf("overLimit") > -1){
                  layer.close(ii);
                  var dataStr=data.split(";");
                  layer.alert("您今日累计转账金额加上本次转账金额共计 "+dataStr[1]+" 元,已经超出了单日转账限额  "+limitTranMoney+" 元",8);
               }else if(data=="isNeedApprove"){
                  layer.close(ii);
                  layer.alert("您账户还没有进行实名认证,请进入安全中心页面进行设置",8,function(){
                     location.href = ctx_root+'/account/safeAction_safe.action';
                   });
               }else if (data == "true") {
                  layer.close(ii);
                  layer.alert("恭喜您！转账成功",9,function(){//对话框中图像:10对勾 8失败苦脸 9成功笑脸  
                    location.href=ctx_root+"/account/assetListAction_queryMyAccountInfo.action";//跳转到我的账户
                  });
               }else{
                  layer.close(ii);
                  layer.alert("转账失败，请稍后重试",8);
               }
            }
         });
     }
   }
   
// 验证微信号 (鼠标离开事件调用)
function checkAccName(filedStr, filedValue) {
   var cash=trim($("#cash").val());
   var isNeedApprove=trim($("#isNeedApprove").val());
   var nohavepassword=trim($("#nohavepassword").val());
   var nohaveTele=trim($("#nohaveTele").val());
   
   if (trim(filedValue) == "" || trim(filedValue).length == 0) {
      $("#accnameMsg").html("请输入对方惠信号码");
         document.getElementById("accnameMsg").style.display="inline";
         document.getElementById("name").innerHTML="";
      return;
   }
   
   $.ajax({
      type : "POST",
      url : "fundRecord_checkFiled.action",
      data : {
         "filed" : filedStr,
         "filedValue" : filedValue
      },
      dataType : 'text',
      success : function(data) {
         if(data=="ismyself"){
            $("#accnameMsg").html("不能输入自己的惠信号");
            document.getElementById("accnameMsg").style.display="inline";
            document.getElementById("name").innerHTML="";
            changeForbidden(1);
         }else if (data == "false") {
            $("#accnameMsg").html("惠信号不存在");
            document.getElementById("accnameMsg").style.display="inline";
            document.getElementById("name").innerHTML="";
            changeForbidden(1);
         }else if(data=="needApprove"){
            $("#accnameMsg").html("对方账号还没有进行实名认证, 不能对其进行转账");
            document.getElementById("accnameMsg").style.display="inline";
            document.getElementById("name").innerHTML="";
            changeForbidden(1);
         } else {
            if(Number(cash)!=0&&isNeedApprove!="ok"&&nohavepassword!="ok"&&nohaveTele!="ok"){//已认证 ，余额不等于0,支付密码已经设置,已绑定手机号码
               changeOk();
            }
            $("#accnameMsg").html("");
            $("#nameMsg").html("");
            document.getElementById("accnameMsg").style.display="none";
            document.getElementById("nameMsg").style.display="none";
            var user = eval(data);
            document.getElementById("name").innerHTML="*"+user[0].realName.substring(1,user[0].realName.length);//用*代替姓
         }
      }
   });
}

//输入转账金额 自动验证
function transfercalculate(amount) {
   var cash=trim($("#cash").val());
   var isNeedApprove=trim($("#isNeedApprove").val());
   var nohavepassword=trim($("#nohavepassword").val());
   var systransferFeeRate = $("#systransferFeeRate").val();//互转费率
   var freeRateMoney=cash;
   
   var fmo=(amount*systransferFeeRate/100);
   if(systransferFeeRate>0){
      freeRateMoney=tomyToFixed((cash-tomyToFixed(fmo+"")+"")); //算出手续费后的余额 截取小数点后两位 不用四舍五入
   }
   
   var fee=tomyToFixed(fmo+"");//手续费 
   var mmo=(cash*systransferFeeRate/100); 
   var maxTranMoney=tomyToFixed(cash-tomyToFixed(mmo+"")+""); //扣除手续费 最多可以转账金额  截取小数点后两位 不用四舍五入
   
   var money = amount-freeRateMoney;
   var bigAmount=amount-cash;
   
   if (isNaN(Number(amount))) {
      $("#transferamountMsg").html("转账金额格式错误");
      document.getElementById("transferamountMsg").style.display="inline";
      $("#transferamount").val("");
      return false;
   }
   // 只能输入小数点后两位
   var indexOfPoint = amount.indexOf('.');
   var t1 = amount.substring(0, 1);
   var t2 = amount.substring(1, 2);
   if (indexOfPoint != -1) {
      if (amount.length > indexOfPoint + 3) {
         $("#transferamount").val(amount.substring(0, indexOfPoint + 3));
      }
   }
   if ((t1 == 0 && t2 == 0 && t2 != '')|| (t1 == 0 && t2 != 0 && t2 != '.')) {
      $("#transferamount").val('');
   }
   if (Number(amount) == 0) {
      $("#transferamountMsg").html("转账金额不能为0元");
      document.getElementById("transferamountMsg").style.display="inline";
      return false;
   }if(money>0){
      $("#transferamountMsg").html("余额不足  (扣除手续费: "+fee+" 元,最多还可以转账金额: "+maxTranMoney+" 元)");
      if(bigAmount>0){
         $("#transferamountMsg").html("余额不足");
      }
      document.getElementById("transferamountMsg").style.display="inline";
      changeForbidden(2);
      return false;
   }else{
      if(tflags==true&&isNeedApprove!="ok"&&nohavepassword!="ok"){//已认证 ，余额不等于0,支付密码已经设置
         changeOk();    
      }
   }
   $("#transferamountMsg").html("");
   document.getElementById("transferamountMsg").style.display="none";
}

 
function checkVal(value, strtype) {
	if (trim(value) != "" || trim(value).length != 0) {
		$("#" + strtype).html("");
	}
}

// ---------------------------提现-------------------------------
var wflag=true;
function sureWith(remark,userid) {//remark=1表示按钮确认提现 2表示输入验证码按钮确定
		if(!wflag){
			return;
		}
		var amount =trim($("#withamount").val());
		var cash=$("#cash").val();//余额
		var withpay = trim($("#withpay").val());
		var bankcode = trim($("#bankcode").val());
		var freeMoneyUse = trim($("#freeCash").val());
		var surplusFreeMoney=trim($("#surplusFreeMoney").val());//使用过了的 可免费提现金额
		var fee= $("#freemoneyval").val();//手续费
		var moneys = amount-cash;
		
		if (amount.replace(/\s+/g, "") == "") {
			$("#withamountMsg").html("请输入提现金额");
			document.getElementById("withamountMsg").style.display="inline";
			return false;
		}
		if (amount.indexOf(".")==amount.length-1) {
			$("#withamountMsg").html("金额格式错误");
			document.getElementById("withamountMsg").style.display="inline";
			return false;
		}
		var count = amount.split(".");	
		if (count.length == 2) {
			if (count[1].length > 2) {
				$("#withamountMsg").html("提现金额最多是两位小数");
				document.getElementById("withamountMsg").style.display="inline";
				return false;
			}
		}
		if (amount < 100) {
			$("#withamountMsg").html("提现最小金额不能低于100元");
			document.getElementById("withamountMsg").style.display="inline";
			return false;
		} /*else if ((trim(amount).length > 6&&amount.indexOf(".")==-1)||(trim(amount).length > 9&&amount.indexOf(".")>0)) {
			$("#withamountMsg").html("提现金额长度不能超过6位数");
			document.getElementById("withamountMsg").style.display="inline";
			return false;
		}*/else if(moneys>0){
			$("#withamountMsg").html("余额不足");
			document.getElementById("withamountMsg").style.display="inline";
			$('#towithdrwa').removeClass('btn');
			$('#towithdrwa').addClass('grey_btn');
			wflag=false;
			return false;
		}
		$("#withamountMsg").html('');
		document.getElementById("withamountMsg").style.display="none";
		if (trim(withpay) == "" || trim(withpay).length == 0) {
			$("#withpayMsg").html("请输入支付密码");
			document.getElementById("withpayMsg").style.display="inline";
			return false;
		} else if (trim(withpay).length < 8 || trim(withpay).length > 16) {
			$("#withpayMsg").html("支付密码输入不正确");
			document.getElementById("withpayMsg").style.display="inline";
			return false;
		}
		
        var code ="";//手机验证码
	    $("#withpayMsg").html("");
		document.getElementById("withpayMsg").style.display="none";
		if(remark!=1){//输入验证码 确定
		        code = $("#withdrawPaySmsCode").val();
			if(trim(code)==""){
				$("#withdrawPaySmsMsg").html("请输入手机验证码");
				document.getElementById("withdrawPaySmsMsg").style.display="inline";
				return;
			}else if(isNaN(Number(trim(code)))||trim(code).length!=6){
				$("#withdrawPaySmsMsg").html("手机验证码是6位数字");
				document.getElementById("withdrawPaySmsMsg").style.display="inline";
				return;
			}
		}
		surerecharge_Sub(amount,withpay,bankcode,fee,freeMoneyUse,code,surplusFreeMoney);
	}

// 确定提现
function surerecharge_Sub(applyAmount,passw,bankcode,fee,freeMoneyUse,code,surplusFreeMoney) {
		passw = rsaData(passw);
		var datastr=getdataStr(applyAmount,passw,bankcode,freeMoneyUse,fee,code,surplusFreeMoney);
		var ii = layer.load('提交中...');
		
		$("#withdrawPaySmsMsg").html("");//清空短信验证码 验证信息
		document.getElementById("withdrawPaySmsMsg").style.display="none";
		
		if (this.ajaxRequest_ != undefined && this.ajaxRequest_.readyState < 4) {
            return;
        }else{
 	      this.ajaxRequest_=$.ajax({
			type : "POST",
			url : "fundRecord_sureWithdraw.action",
			data :datastr,
			dataType : 'text',
			success : function(data) {
				if(data=="isSendMesCode"){
					$("#withdrawPaySmsCode").val('');//清空验证码文本框
					
					layer.close(ii);
					var remark="withdraw";
					$("#"+remark+"PaySmsMsg").html('');
					resetTimer(remark+"PaySms");
					$("#"+remark+"PaySms").show();
					$("#"+remark+"PaySmsD").show();
				}else if(data == "error"){
					layer.close(ii);
					$("#withpayMsg").html("支付密码错误,请重新输入");
					document.getElementById("withpayMsg").style.display="inline";
				}else if(data == "teleCodeError"){
					layer.close(ii);
					$("#withdrawPaySmsMsg").html("验证码错误,请重新输入");
					document.getElementById("withdrawPaySmsMsg").style.display="inline";
				}else if(data.indexOf("isOver24H") >-1){
	            	   layer.close(ii);
	            	   var checkTime=data.split(";");
	                   layer.alert("为了您的资金安全，修改银行卡信息后，"+checkTime[1]+"小时内不允许提现!",8);
	            }else if (data == "true") {
					$.ajax({//异步发送短信
						type : "POST",
						url : "fundRecord_sendMessage.action",
						data :{"transfemoney":applyAmount},
						dataType : 'text',
						success : function(data) {}
					});
					
					$("#withpayMsg").html("");  
					document.getElementById("withpayMsg").style.display="none";
					layer.close(ii);
					layer.alert("恭喜您！提现申请成功",9,function(){
						location.href=ctx_root+"/account/assetListAction_queryMyAccountInfo.action";//跳转到我的账户
					});
				}else {
					layer.close(ii);
					layer.alert("提现申请失败，请稍后重试",8);
				}
			}
		});
        }
	}

//获得参数
function getdataStr(applyAmount,passw,bankcode,freeMoneyUse,fee,code,surplusFreeMoney){
      var data="";
      data= {
         "wit.applyAmount" : applyAmount,//申请金额
         "user.payPwd":passw,
         "bankCode":bankcode,//银行代码
         "wit.freeMoneyUse":surplusFreeMoney,//使用了的 可免费提现金额
         "wit.calculateFee":fee,//手续费
         "teleCode":code//验证码
          };
   return data;
}

//超出提现设置金额 需输入验证码时候 验证支付密码
function surerecharge_SubCheckpaypass(passw,userId,remark,remarkPay) {
	$.ajax({
		type : "POST",
		url : "fundRecord_sureWithdrawCheckpaypass.action",
		data : {
			"user.payPwd":passw
		},
		dataType : 'text',
		success : function(data) {        
			if(data == "error"){
				$("#"+remarkPay).html("支付密码错误,请重新输入");
				document.getElementById(remarkPay).style.display="inline";
			}else if(data == "nohaveTele"){
				layer.alert("您账户还没有绑定手机号码,请进入安全中心页面进行绑定设置",8,function(){
					location.href = ctx_root+'/account/safeAction_safe.action';
			    });
			}else {
				$("#"+remark+"PaySmsMsg").html('');
				resetTimer(remark+"PaySms");
				$("#"+remark+"PaySms").show();
				$("#"+remark+"PaySmsD").show();
			} 
			
		}
	});
}
 
//输入验证自动验证(onkeyup事件调用)
function calculate(amount) {
   var bankCardId=$("#bankCardId").val();//是否绑定卡号
   var isOver24H=$("#isOver24H").val(); //修改卡号是否超过24h
   var isSetPayPasswordw=trim($("#isSetPayPasswordw").val());
   var nohaveTele=trim($("#nohaveTele").val());
   var isNeedApprove=trim($("#isNeedApprove").val());
   var cash=$("#cash").val();//余额
   var moneys = amount-cash;
   
   if (isNaN(Number(amount))) {
      $("#withamountMsg").html("提现金额格式错误");
      document.getElementById("withamountMsg").style.display="inline";
      $("#withamount").val("");
      $("#freemoney").text("0.00");
      return false;
   }
   // 只能输入小数点后两位
   var indexOfPoint = amount.indexOf('.');
   var t1 = amount.substring(0, 1);
   var t2 = amount.substring(1, 2);
   if (indexOfPoint != -1) {
      if (amount.length > indexOfPoint + 3) {
         $("#withamount").val(amount.substring(0, indexOfPoint + 3));
         return false;
      }
   }if ((t1 == 0 && t2 == 0 && t2 != '')//不能输入类似金额00012
         || (t1 == 0 && t2 != 0 && t2 != '.')) {
      $("#withamount").val('');
   }if(Number(amount) < 100) {
      $("#withamountMsg").html("提现金额不能小于100元");
      document.getElementById("withamountMsg").style.display="inline";
      $("#freemoney").text("0.00");
      return false;
   }else if(Number(moneys)>0){
      $("#withamountMsg").html("余额不足");
      document.getElementById("withamountMsg").style.display="inline";
      $('#towithdrwa').removeClass('btn');
      $('#towithdrwa').addClass('grey_btn');
      $("#freemoney").text("0.00");
      wflag=false;
      return false;
   }else{
      if((bankCardId!="ok"&& bankCardId!=null)&&isOver24H!="no"&&isSetPayPasswordw!="ok"&&nohaveTele!="ok"&&isNeedApprove!="ok"){//已经绑定卡号和修改卡号已过24h,支付密码已经设置
         $('#towithdrwa').removeClass('grey_btn');
         $('#towithdrwa').addClass('btn');
         wflag=true;
      }
   }
   $("#withamountMsg").html("");
   document.getElementById("withamountMsg").style.display="none";
}

//自动算取提现手续费(onkeyup事件调用)
function getWithdrawFee(amount) {
	  var cash=$("#cash").val();//余额
	  var moneys = amount-cash;
	  
	  if((moneys<0||moneys==0)&&(amount>100||amount==100)){//余额足够时候 才去计算
			$.ajax({
				type : "POST",
				url : "fundRecord_getWithdrawFee.action?transfemoney="+amount,
				dataType : 'json',
				success : function(data) {
					 if(data!=null){
						 var fee=tomyToFixed(data[0].withDrawRateMoney+"");//管理费
						 var surplusFreeMoney=tomyToFixed(data[0].withDrawFreeMoney+"");//本次使用了的 可免费提现金额
					    	 $("#freemoney").text(fee);
					    	 $("#freemoneyval").val(fee);
							 $("#surplusFreeMoney").val(surplusFreeMoney); 
					 }
				}
			});
    }  
}

// 输入验证自动验证
function checkpassword(withpay) {
	if (trim(withpay) != "" || trim(withpay).length != 0) {
		$("#withpayMsg").html("");
		document.getElementById("withpayMsg").style.display="none";
	}
}

//修改银行卡
function to_safe() {
	location.href = ctx_root+'/account/safeAction_safe.action';
}

function trim(str) { // 删除左右两端的空格
	return str.replace(/(^\s*)|(\s*$)/g, "");
}


//截取小数点后两位 不用四舍五入
function tomyToFixed(money){
	if(money.indexOf(".")<0){
		 money+=".00";
	 }
	 var newmoney="0.00";	
	 if(isnotEmpty(money)){
		 newmoney=(money.substring(0,money.indexOf(".")+3)*1).toFixed(2);
	 }
	 return newmoney;
}

//验证非空
function isnotEmpty(vals){
	var bool=false;
	if(vals!=""&&vals!="undefined"&&vals!=null&&vals.length>0){
		bool=true;
	}
	return bool;
}

function clearAccnameMsg(){
	$("#accnameMsg").html("");
	document.getElementById("name").innerHTML="";
	document.getElementById("accnameMsg").style.display="none";
}

//置确定按钮灰色
function changeForbidden(rem){
	$('#totransfer').removeClass('btn');
	$('#totransfer').addClass('grey_btn');
	if(rem==1){
		tflags=false;
	}
	tflag=false;
}

//显示确定
function changeOk(){
	$('#totransfer').removeClass('grey_btn');
	$('#totransfer').addClass('btn');
	tflag=true;
	tflags=true;
}
